/**
 * 组件：ImageButton 图片按钮组件
 * Author:Colin3dmax
 */
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {
    StyleSheet,
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

class ImageButton extends Component {

    static propTypes = {
        style: View.propTypes.style,
        touchStyle: View.propTypes.style,
        imageStyle:Image.propTypes.style,
        source: Image.propTypes.source,
        onPress: PropTypes.func,
    }

    static defaultProps = {}

    constructor(props) {
        super(props)
        this.state = {}
    }

    componentDidMount() {

    }


    render() {
        const {touchStyle,imageStyle, style, source, onPress} = this.props
        return (
            <View style={[styles.container, style]}>
                <TouchableOpacity style={touchStyle} onPress={onPress}>
                    <Image style={[styles.imageIcon,imageStyle]} source={source}/>
                </TouchableOpacity>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        height: 32,
        width: 32,
    },
    imageIcon: {
        width: 32,
        height: 32,
        resizeMode: 'contain',
    },
});

export default ImageButton;